import React from 'react';
import ReactDOM from 'react-dom';
import {createStore,combineReducers} from 'redux'
import {Provider} from 'react-redux'
import './index.css';
import RouterComponent from './routes/index'
import * as serviceWorker from './serviceWorker';

let off=false;
if (localStorage.goods){
    off=true
} else {
    off=false
}
function counterReducer(state={amount:off},action) {
    switch (action.type) {
        case 'cart':
            return {amount: action.amount};
        default:
            return state
    }
}

let reducer=combineReducers({
   userInfo:counterReducer
});

let store = createStore(reducer);

class Index extends React.Component{
    render() {
        return(
            <Provider store={store}>
                <RouterComponent></RouterComponent>
            </Provider>
        )
    }
}

ReactDOM.render(
    <Index />,
  document.getElementById('root')
);

// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.unregister();
